﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


using System.Runtime.InteropServices;

namespace InControl
{
    public partial class INV_people_form : Form
    {
        public INV_people_form()
        {
            InitializeComponent();
            name_panel.Visible = true;
            phone_panel.Visible = false;
            email_panel.Visible = false;
        }

        public void INV_load_people_form(object sender, EventArgs e) 
        {
            textBox1.Text = null; textBox2.Text = null; textBox3.Text = null; textBox4.Text = null; textBox6.Text = null;
            textBox5.Text = null; textBox9.Text = null; textBox8.Text = null; textBox11.Text = null;
        }

        private void label4_Click(object sender, EventArgs e)
        {
            pass_panel.Visible = false;
            name_panel.Visible = true;
            phone_panel.Visible = false;
            email_panel.Visible = false;
        }

        private void phone_panel_Paint(object sender, PaintEventArgs e)
        {

        }

        private void pictureBox4_Click(object sender, EventArgs e)
        {
            label4_Click(sender, e);
        }

        private void pictureBox5_Click(object sender, EventArgs e)
        {
            label1_Click(sender, e);
        }

        private void label1_Click(object sender, EventArgs e)
        {
            pass_panel.Visible = false;
            name_panel.Visible = false;
            email_panel.Visible = false;
            phone_panel.Visible = true;
        }

        private void pictureBox6_Click(object sender, EventArgs e)
        {
            label5_Click(sender, e);
        }

        private void label5_Click(object sender, EventArgs e)
        {
            pass_panel.Visible = false;
            email_panel.Visible = true;
            name_panel.Visible = false;
            phone_panel.Visible = false;
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            ((INV_MDIParent)this.MdiParent).OpenForm(typeof(INV_initpeople_form));
        }

        private void Off_Edit_Panel_Paint(object sender, PaintEventArgs e)
        {

        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox6.Text != "" && textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" &&
                    textBox9.Text != "" && textBox10.Text != "" && textBox11.Text != "")
                {
                    if (textBox10.Text != textBox11.Text)
                    {
                        textBox10.BackColor = Color.LightCoral; 
                        textBox11.BackColor = Color.LightCoral;
                        pass_panel.Visible = true;
                        throw new Exception("ERROR: \nPassword mismatch");
                    }
                    ((INV_MDIParent)this.MdiParent).appDriver.AddNewEmployee(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox6.Text, textBox5.Text, textBox9.Text, textBox8.Text, textBox11.Text);
                    Error_form ef = new Error_form();
                    ef.richTextBox1.Text = "employee saved";
                    ef.ShowDialog(this);
                }
                else
                {
                    textBox6.BackColor = Color.LightCoral; textBox1.BackColor = Color.LightCoral; textBox2.BackColor = Color.LightCoral;
                    textBox3.BackColor = Color.LightCoral; textBox9.BackColor = Color.LightCoral; textBox10.BackColor = Color.LightCoral;
                    textBox11.BackColor = Color.LightCoral;
                    throw new Exception("ERROR: \n please review form");
                }
            }
            catch (Exception ex)
            {
                Error_form ef = new Error_form();
                ef.richTextBox1.Text = ex.Message;
                ef.ShowDialog(this);
            }
        }
        

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void label6_Click(object sender, EventArgs e)
        {
            email_panel.Visible = false;
            name_panel.Visible = false;
            phone_panel.Visible = false;
            pass_panel.Visible = true;
        }

        private void pictureBox7_Click(object sender, EventArgs e)
        {
            label6_Click(sender, e);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
